using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using DataTransferObject;
using Business;
namespace Presentation.UserControlls
{
    public partial class UC_TheHetHan : UserControl
    {
        clsDocGiaBUS docgiaBUS = new clsDocGiaBUS();
        clsDocGiaDTO docgiaDTO = new clsDocGiaDTO();
        BindingSource bs = new BindingSource();
        DataTable tbl = new DataTable();
        int tongcong;

        public UC_TheHetHan()
        {
            InitializeComponent();
        }

        private void UC_TheHetHan_Load(object sender, EventArgs e)
        {
            HienThiListView();
            
            
            lbltongcong.Text = Convert.ToString(tongcong);
        }
        public void HienThiListView()
        {
            ListViewItem lvwitem = new ListViewItem();
            tbl = docgiaBUS.DanhSachDocGia();
            foreach (DataRow dr in tbl.Rows)
            {
                DateTime ngayhethan = Convert.ToDateTime(dr["ngayhethan"]);
                if (DateTime.Now > ngayhethan)
                {
                    tongcong = tongcong + 1;
                    lvwitem = new ListViewItem();
                    lvwitem.Text = dr["MATHE"].ToString();
                    lvwitem.SubItems.Add(dr["HOTEN"].ToString());
                    DateTime ngaylapthe = Convert.ToDateTime(dr["NGAYLAPTHE"].ToString());
                   // DateTime ngayhethan = Convert.ToDateTime(dr["NGAYHETHAN"].ToString());
                    lvwitem.SubItems.Add(ngaylapthe.ToShortDateString());
                    lvwitem.SubItems.Add(ngayhethan.ToShortDateString());
                    lvwthehethan.Items.Add(lvwitem);
                }
            }
        }
       
        private void btnThoat_Click(object sender, EventArgs e)
        {
            DialogResult dlg = new DialogResult();
            dlg = DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn thoát không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                this.ParentForm.Close();

            }
        }
    }
}
